package com.ruoyi.web.controller.cs;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.CheckSwitch;
import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.cs.domain.TExchange;
import com.ruoyi.cs.domain.TUser;
import com.ruoyi.cs.domain.vo.*;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.cs.mapper.TUserMapper;
import com.ruoyi.cs.service.ITBackpackService;
import com.ruoyi.cs.service.ITUserService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.ruoyi.system.service.ISysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.TGoods;
import com.ruoyi.cs.service.ITGoodsService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 饰品信息Controller
 * 
 * @author ruoyi
 * @date 2021-03-25
 */
@Api(tags = {"饰品信息管理"})
@RestController
@RequestMapping("/cs/goods")
@SuppressWarnings("all")
public class TGoodsController extends BasicsController
{
    private static final Logger log = LoggerFactory.getLogger(TGoodsController.class);
    @Autowired
    private ITGoodsService tGoodsService;
    @Autowired
    private ISysDictDataService sysDictDataService;
    @Autowired
    private ITBackpackService tBackpackService;
    @Autowired
    private ITUserService tUserService;
    @Autowired
    private TokenService tokenService;

    /**
     * 修改饰品信息
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:edit')")
    @ApiOperation("修改饰品信息")
    @RequestMapping(name="修改饰品信息",value="edit",method = RequestMethod.POST)
    @Log(title = "饰品信息", businessType = BusinessType.UPDATE)
    public Response edit(@RequestBody TGoods tGoods)
    {
        return  tGoodsService.updateTGoods(tGoods);
    }

    /**
     * 删除饰品信息
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:remove')")
    @ApiOperation("删除饰品信息")
    @RequestMapping(name="删除饰品信息",value="remove",method = RequestMethod.GET)
    @Log(title = "饰品信息", businessType = BusinessType.DELETE)
    @ApiImplicitParam(name = "goodsIds",value = "要删除的饰品ID，多个用，分开" ,dataType = "String", paramType = "query", required = false)
    public Response remove(String goodsIds)
    {
        if (StringUtils.isNotEmpty(goodsIds)) {
            String[] ids = goodsIds.split(",");
            return tGoodsService.deleteTGoodsByIds(ids);
        }else{
            return Response.fail(Constants.FAILCODE,"参数不能为空!");
        }
    }

    /**
     * 批量停用饰品信息
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:stop')")
    @ApiOperation("批量停用饰品信息")
    @RequestMapping(name="批量停用饰品信息",value="stop",method = RequestMethod.GET)
    @Log(title = "饰品信息", businessType = BusinessType.STOP)
    @ApiImplicitParam(name = "goodsIds",value = "要停用的饰品ID，多个用，分开" ,dataType = "String", paramType = "query", required = false)
    public Response stop(String goodsIds)
    {
        if (StringUtils.isNotEmpty(goodsIds)) {
            String[] ids = goodsIds.split(",");
            return tGoodsService.batchStopTGoods(ids);
        }else{
            return Response.fail(Constants.FAILCODE,"参数不能为空!");
        }
    }

    /**
     * 批量启用饰品信息
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:enable')")
    @ApiOperation("批量启用饰品信息")
    @RequestMapping(name="批量启用饰品信息",value="enable",method = RequestMethod.GET)
    @Log(title = "饰品信息", businessType = BusinessType.ENABLE)
    @ApiImplicitParam(name = "goodsIds",value = "要启用的饰品ID，多个用，分开" ,dataType = "String", paramType = "query", required = false)
    public Response enable(String goodsIds)
    {
        if (StringUtils.isNotEmpty(goodsIds)) {
            String[] ids = goodsIds.split(",");
            return tGoodsService.batchEnableTGoods(ids);
        }else{
            return Response.fail(Constants.FAILCODE,"参数不能为空!");
        }
    }

    /**
     * 批量添加饰品信息
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:batchAdd')")
    @ApiOperation("批量添加饰品信息")
    @RequestMapping(name="批量添加饰品信息",value="batchAdd",method = RequestMethod.POST)
    @Log(title = "饰品信息", businessType = BusinessType.INSERT)
    public Response batchAdd(@RequestBody TGoodsAddVo tGoods)
    {
        return tGoodsService.batchAdd(tGoods);
    }


    /**
     * 幸运饰品统计
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:luckyCount')")
    @ApiOperation("幸运饰品统计")
    @RequestMapping(name="幸运饰品统计",value="luckyCount",method = RequestMethod.GET)
    public Response<Map<String, BigDecimal>> luckyCount(String startTime,String endTime)
    {
        return Response.success(tGoodsService.luckyCount(startTime, endTime));
    }

    /**
      * 幸运饰品饰品列表
      */
    @ApiOperation("幸运饰品饰品列表")
    @PreAuthorize("@ss.hasPermi('cs:goods:luckyListBack')")
    @RequestMapping(name="幸运饰品饰品列表",value="luckyListBack",method = RequestMethod.POST)
    public ResponsePageInfo<LuckyTGoodsVo> luckyListBack(@RequestBody LuckyTGoodsVo tGoods)
    {
        startPage(tGoods.getPageNum(), tGoods.getPageSize());
        tGoods.setBackStage(Constants.BACKSTAGE);
        tGoods.setGoodsBelongingType(Constants.GOOGSBLTYPE2);
        List<LuckyTGoodsVo> list = tGoodsService.luckyGoodsListBack(tGoods);
        return toResponsePageInfo(list);
    }

    /**
     * 保底饰品列表
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:floorsListBack')")
    @ApiOperation("保底饰品列表")
    @RequestMapping(name="保底饰品列表",value="floorsListBack",method = RequestMethod.POST)
    public ResponsePageInfo<TGoods> floorsListBack(@RequestBody TGoods tGoods)
    {
        startPage(tGoods.getPageNum(), tGoods.getPageSize());
        tGoods.setBackStage(Constants.BACKSTAGE);
        tGoods.setGoodsBelongingType(Constants.GOOGSBLTYPE4);
        List<TGoods> list = tGoodsService.floorsGoodsListBack(tGoods);
        return toResponsePageInfo(list);
    }


    /**
     * 保底饰品添加
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:floorsTGoodsAdd')")
    @ApiOperation("保底饰品添加")
    @RequestMapping(name="保底饰品添加",value="floorsTGoodsAdd",method = RequestMethod.POST)
    @Log(title = "保底饰品添加", businessType = BusinessType.INSERT)
    public Response floorsTGoodsAdd(@RequestBody TGoods tGoods)
    {
        return tGoodsService.floorsTGoodsAdd(tGoods);
    }

    /**
     * 保底饰品编辑
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:floorsTGoodsEdit')")
    @ApiOperation("保底饰品编辑")
    @RequestMapping(name="保底饰品编辑",value="floorsTGoodsEdit",method = RequestMethod.POST)
    @Log(title = "保底饰品编辑", businessType = BusinessType.UPDATE)
    public Response floorsTGoodsEdit(@RequestBody TGoods tGoods)
    {
        return tGoodsService.floorsTGoodsEdit(tGoods);
    }

    /**
     * 默认保底饰品查询
     */
    @ApiOperation("默认保底饰品查询")
    @PreAuthorize("@ss.hasPermi('cs:goods:defaultTGoods')")
    @RequestMapping(name="默认保底饰品查询",value="defaultTGoods",method = RequestMethod.GET)
    public Response<String> defaultTGoods()
    {
        SysDictData ss = sysDictDataService.selectDictDataById(139L);
        return Response.success(ss.getDictValue());
    }

    /**
     * 默认保底饰品编辑
     */
    @ApiOperation("默认保底饰品编辑")
    @PreAuthorize("@ss.hasPermi('cs:goods:defaultTGoodsSet')")
    @RequestMapping(name="默认保底饰品编辑",value="defaultTGoodsSet",method = RequestMethod.GET)
    @Log(title = "默认保底饰品编辑", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "value",value = "默认保底饰品id" ,dataType = "String", paramType = "query", required = true)
    public Response<Integer> defaultTGoodsSet(String value)
    {
        String listClass = tGoodsService.defaultTGoodsSet(value);
        int row = sysDictDataService.updateDefualtValue(value,"139",listClass);
        return toResponse(row);
    }
    /**
     * 幸运饰品的溢价值设置
     */
    @ApiOperation("幸运饰品的溢价值设置")
        @PreAuthorize("@ss.hasPermi('cs:goods:luckGoodsPremiumRate')")
    @RequestMapping(name="幸运饰品的溢价值设置",value="luckGoodsPremiumRate",method = RequestMethod.GET)
    @Log(title = "幸运饰品的溢价值设置", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "premiumRate",value = "溢价值" ,dataType = "double", paramType = "query", required = true)
    public Response<String> luckGoodsPremiumRate(String premiumRate)
    {
        tGoodsService.updatePremiumRate(premiumRate,Constants.GOOGSBLTYPE2);
        return Response.success("修改成功");
    }


    /**
     * 幸运饰品系数设置
     */
    @ApiOperation("幸运饰品系数设置")
    @PreAuthorize("@ss.hasPermi('cs:goods:coefficientSet')")
    @RequestMapping(name="幸运饰品系数设置",value="coefficientSet",method = RequestMethod.GET)
    @Log(title = "幸运饰品系数设置", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "value",value = "默认保底饰品id" ,dataType = "String", paramType = "query", required = true)
    public Response<Integer> coefficientSet(String value)
    {
        int row = sysDictDataService.updateValue(value,"138");
        return toResponse(row);
    }
    /**
     * 幸运饰品系数值
     */
    @ApiOperation("幸运饰品系数值")
    @PreAuthorize("@ss.hasPermi('cs:goods:coefficientVal')")
    @RequestMapping(name="幸运饰品系数值",value="coefficientVal",method = RequestMethod.GET)
    public Response<Integer> coefficientVal()
    {
        SysDictData ss = sysDictDataService.selectDictDataById(138L);
        return Response.success(ss.getDictValue());
    }
    /**
     * 溢价值
     */
    @ApiOperation("溢价值")
    @PreAuthorize("@ss.hasPermi('cs:goods:premiumVal')")
    @RequestMapping(name="溢价值",value="premiumVal",method = RequestMethod.GET)
    @ApiImplicitParam(name = "type",value = "溢价设置类型" ,dataType = "String", paramType = "query", required = true)
    public Response<Integer> premiumVal(String type)
    {
        if (StringUtils.isEmpty(type)) {
            return Response.fail(Constants.FAILCODE,"溢价设置类型不能为空!");
        }
        SysDictData ss = null;
        if (Constants.GOOGSBLTYPE0.equals(type)){
           ss = sysDictDataService.selectDictDataById(140L);
        }else if (Constants.GOOGSBLTYPE1.equals(type)) {
           ss = sysDictDataService.selectDictDataById(142L);
        }else if (Constants.GOOGSBLTYPE3.equals(type)) {
            ss = sysDictDataService.selectDictDataById(210L);
        }
        else {
           ss = sysDictDataService.selectDictDataById(141L);
        }
        return Response.success(ss.getDictValue());
    }
    /**
     * 溢价设置
     */
    @ApiOperation("溢价设置")
    @PreAuthorize("@ss.hasPermi('cs:goods:premiumSet')")
    @RequestMapping(name="溢价设置",value="premiumSet",method = RequestMethod.GET)
    @Log(title = "溢价设置", businessType = BusinessType.UPDATE)
    @Transactional
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type",value = "溢价设置类型" ,dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "val",value = "溢价值" ,dataType = "String", paramType = "query", required = true)
    })
    public Response premiumSet(String type,String val)
    {
        if (StringUtils.isEmpty(type) || StringUtils.isEmpty(val)) {
            return Response.fail(Constants.FAILCODE,"溢价设置类型、和值都不能为空!");
        }
        if (Constants.GOOGSBLTYPE0.equals(type)){
            int row = sysDictDataService.updateValue(val,"140");
        }else if (Constants.GOOGSBLTYPE1.equals(type)) {
            int row = sysDictDataService.updateValue(val,"142");
        }else if (Constants.GOOGSBLTYPE3.equals(type)) {
            int row = sysDictDataService.updateValue(val,"210");
        }else {
            int row = sysDictDataService.updateValue(val,"141");
        }
        tGoodsService.premiumSet(type,val);
        return Response.success();
    }


    /**
     * 饰品商城统计
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:shoppingMallCount')")
    @ApiOperation("饰品商城统计")
    @RequestMapping(name="饰品商城统计",value="shoppingMallCount",method = RequestMethod.GET)
    public Response<Map<String, Object>> shoppingMallCount()
    {
        return Response.success(tGoodsService.shoppingMallCount());
    }

    /**
     * 饰品商城 饰品统计列表
     * @param tGoods
     * @return
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:shoppingMallListBack')")
    @ApiOperation("饰品商城 饰品统计列表")
    @RequestMapping(name="饰品商城 饰品统计列表",value="shoppingMallListBack",method = RequestMethod.POST)
    public ResponsePageInfo<TGoodsShoppingBackVo> shoppingMallListBack(@RequestBody TGoodsShoppingBackVo tGoodsShoppingBackVo)
    {
        String sb = " goods_price desc";
        if ("0".equals(tGoodsShoppingBackVo.getSortType())){
             sb = " goods_price desc";
        }else if ("1".equals(tGoodsShoppingBackVo.getSortType())){
             sb = " saleNum desc";
        }else if ("2".equals(tGoodsShoppingBackVo.getSortType())){
             sb = " profitTotal desc";
        }
        startPage(tGoodsShoppingBackVo.getPageNum(), tGoodsShoppingBackVo.getPageSize(),sb);
        List<TGoodsShoppingBackVo> list = tGoodsService.shoppingMallListBack(tGoodsShoppingBackVo);
        return toResponsePageInfo(list);
    }

    /**
     * 饰品商城 饰品添加
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:shoppingMallAdd')")
    @ApiOperation("饰品商城 饰品添加")
    @RequestMapping(name="饰品商城 饰品添加",value="shoppingMallAdd",method = RequestMethod.POST)
    @Log(title = "饰品商城", businessType = BusinessType.INSERT)
    public Response shoppingMallAdd(@RequestBody TGoodsShoppingBackVo tGoodsShoppingBackVo)
    {
        if (StringUtils.isEmpty(tGoodsShoppingBackVo.getGoodsPoolId())) {
            return Response.fail(Constants.FAILCODE,"饰品池ID(goodsPollId)不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getAddStocknum())) {
            return Response.fail(Constants.FAILCODE,"饰品库存数量(addStocknum)设置不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getGoodsGrate())) {
            return Response.fail(Constants.FAILCODE,"饰品颜色(goodsGrate)设置不能为空!");
        }
        return tGoodsService.shoppingMallAdd(tGoodsShoppingBackVo);
    }

    /**
     * 饰品商城 饰品编辑
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:shoppingMallUpdate')")
    @ApiOperation("饰品商城 饰品编辑")
    @RequestMapping(name="饰品商城 饰品编辑",value="shoppingMallUpdate",method = RequestMethod.POST)
    @Log(title = "饰品商城", businessType = BusinessType.UPDATE)
    public Response shoppingMallUpdate(@RequestBody TGoodsShoppingBackVo tGoodsShoppingBackVo)
    {
        if (StringUtils.isEmpty(tGoodsShoppingBackVo.getGoodsId())) {
            return Response.fail(Constants.FAILCODE,"饰品ID(goodsId)不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getAddStocknum())) {
            return Response.fail(Constants.FAILCODE,"饰品库存数量(addStocknum)设置不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getDelFlag())) {
            return Response.fail(Constants.FAILCODE,"是否上架(delFlag)设置不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getGoodsGrate())) {
            return Response.fail(Constants.FAILCODE,"饰品颜色(goodsGrate)设置不能为空!");
        }
        if (StringUtils.isNull(tGoodsShoppingBackVo.getGoodsPrice())) {
            return Response.fail(Constants.FAILCODE,"饰品价格(goodsPrice)设置不能为空!");
        }
        return tGoodsService.shoppingMallUpdate(tGoodsShoppingBackVo);
    }
    /**
     * 饰品商城 饰品上下架状态编辑
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:editDelfalg')")
    @ApiOperation("饰品商城 饰品上下架状态编辑")
    @RequestMapping(name="饰品商城 饰品上下架状态编辑",value="editDelfalg",method = RequestMethod.GET)
    @Log(title = "饰品商城", businessType = BusinessType.UPDATE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId",value = "饰品Id" ,dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "delFlag",value = "上下架状态" , dataType = "String", paramType = "query", required = false),
    })
    public Response<Integer> editDelfalg(@RequestParam(value = "goodsId",required = true) String goodsId,
                                  @RequestParam(value = "delFlag",required = true) String delFlag)
    {
        return toResponse(tGoodsService.editDelfalg(goodsId,delFlag));
    }


    /**
     * 饰品商城 饰品购买记录
     * @param tGoods
     * @return
     */
    @PreAuthorize("@ss.hasPermi('cs:goods:shoppingMallBuyList')")
    @ApiOperation("饰品商城 饰品购买记录")
    @RequestMapping(name="饰品商城",value="shoppingMallBuyList",method = RequestMethod.POST)
    public ResponsePageInfo<TBackPackShoppingBackVo> shoppingMallBuyList(@RequestBody TBackPackShoppingBackVo tBackPackShoppingBackVo)
    {
        startPage(tBackPackShoppingBackVo.getPageNum(), tBackPackShoppingBackVo.getPageSize());
        List<TBackPackShoppingBackVo> list = tGoodsService.shoppingMallBuyList(tBackPackShoppingBackVo);
        return toResponsePageInfo(list);
    }


//    /**
//     * 更新饰品价格
//     */
//    @ApiOperation("饰品商城 更新饰品价格")
//    @PreAuthorize("@ss.hasPermi('cs:pool:updateGoodsPrice')")
//    @RequestMapping(name = "更新饰品价格", value = "updateGoodsPrice", method = RequestMethod.GET)
//    @Log(title = "饰品商城", businessType = BusinessType.UPDATE)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "type",value = "饰品所属类型 0 箱子 1 ROLL房 2 幸运饰品 3 饰品商城 4 补偿饰品 5 盲盒对战 6 盲盒对战保底饰品" ,dataType = "String", paramType = "query", required = false),
//            @ApiImplicitParam(name = "boxIds",value = "箱子ID" ,dataType = "String", paramType = "query", required = false)
//    })
//    public Response updateGoodsPrice(String type,@RequestParam List<String> boxIds) {
//        try {
//            tGoodsService.updateGoodsPoolPrice(type,boxIds);
//        } catch (Exception e) {
//            log.error("更新失败:{}",e.getMessage());
//            return Response.fail("更新失败:"+e.getMessage());
//        }
//        return Response.success("更新价格成功");
//    }

    /**
     * 饰品列表
     */
    @ApiOperation("箱子饰品列表")
    @PreAuthorize("@ss.hasPermi('cs:pool:updateGoodsPrice')")
    @RequestMapping(name = "箱子饰品列表", value = "boxGoodsList", method = RequestMethod.GET)
    @ApiImplicitParam(name = "boxId",value = "所属箱子ID" ,dataType = "String", paramType = "query", required = false)
    public Response<List<TGoods>> boxGoodsList(String boxId) {
        return Response.success(tGoodsService.boxTGoodsList(Constants.GOOGSBLTYPE0,boxId));
    }

    /*---------------------------------------------前端接口-----------------------------------*/

    /**
     * 幸运饰品  推荐商品列表
     */
    @ApiOperation("web幸运饰品  推荐商品列表")
    @RequestMapping(name="幸运饰品  推荐商品列表",value="common/recommendLuckyList",method = RequestMethod.GET)
    public Response<List<TGoods>> recommendLuckyList(){
        /**推荐商品 0 是 1  否*/
        TGoodsVo tGoodsVo = new TGoodsVo();
        tGoodsVo.setRecommendGoods("0");
        List<TGoods> list = tGoodsService.luckyJewelryList(tGoodsVo);
        return Response.success(list);
    }
    /**
     * 幸运饰品信息列表
     */
    @ApiOperation("web幸运饰品信息列表")
    @RequestMapping(name="幸运饰品信息列表",value="common/luckList",method = RequestMethod.POST)
    public ResponsePageInfo<TGoods> list(@RequestBody  TGoodsVo tGoodsVo)
    {
        startPage();
        List<TGoods> list = tGoodsService.luckyJewelryList(tGoodsVo);
        return toResponsePageInfo(list);
    }
//    /**
//     * 幸运饰品  饰品升级操作
//     */
//    @ApiOperation("web幸运饰品  饰品升级操作")
//    @RequestMapping(name="幸运饰品  饰品升级操作",value="luckyGoodsUpgrate",method = RequestMethod.POST)
//    @Log(title = "饰品商城饰品升级", businessType = BusinessType.INSERT)
//    public Response<List<TGoods>> luckyGoodsUpgrate(@RequestBody TGoodsVo tGoodsVo){
//
//        LoginUser loginUser = tokenService.getLoginUserWeb(ServletUtils.getRequest());
//        if (loginUser != null && StringUtils.isNotEmpty(tGoodsVo.getGoodsId())
//                && tGoodsVo.getUpgradeChance() != null && StringUtils.isNotNull(tGoodsVo.getUpgradeMoney())) {
//            try {
//                SysUser sysUser = loginUser.getUser();
//                String userId = sysUser.getLoginUserId();
//                tGoodsVo.setUserId(userId);
//                return tGoodsService.luckyGoodsUpgrateV1(tGoodsVo);
//            } catch (Exception e) {
//                log.error("幸运饰品升级异常情况：{}",e.getMessage());
//                return Response.fail(Constants.FAILCODE,e.getMessage());
//            }
//        }else {
//            return Response.fail(Constants.FAILCODE,"参数不能为空!");
//        }
//    }

    /**
     * 幸运饰品  饰品升级操作
     */
    @CheckSwitch
    @ApiOperation("web幸运饰品  饰品升级操作")
    @RequestMapping(name="幸运饰品  饰品升级操作",value="luckyGoodsUpgrate",method = RequestMethod.POST)
    @Log(title = "饰品商城饰品升级", businessType = BusinessType.INSERT)
    public Response<LuckyGoodsUpgrateResp> luckyGoodsUpgrate(@Validated  @RequestBody TGoodsUpgrateVo req){
        String userId = tokenService.getLoginUserId();
        return tGoodsService.luckyGoodsUpgrateV2(req,userId);
    }

    /**
     * 饰品商城饰品列表
     */
    @ApiOperation("web饰品商城饰品列表")
    @RequestMapping(name="饰品商城饰品列表",value="common/shoppingMallList",method = RequestMethod.POST)
    @Cacheable(value="twoSecondsCache", key="'shoppingMallList'+#p0")
    public ResponsePageInfo<TGoods> shoppingMallList(@RequestBody  TGoodsVo tGoodsVo){
        startPage();
        List<TGoods> list = tGoodsService.shoppingMallList(tGoodsVo);
        return toResponsePageInfo(list);
    }

    /**
     * 饰品商城 购买功能
     */
    @CheckSwitch
    @ApiOperation("web饰品商城 购买功能")
    @RequestMapping(name="饰品商城 购买功能",value="shoppingBuy",method = RequestMethod.POST)
    @Log(title = "饰品商城购买", businessType = BusinessType.INSERT)
    public Response shoppingBuy(@RequestBody ShoppingVo shoppingVo){

        LoginUser loginUser = tokenService.getLoginUserWeb(ServletUtils.getRequest());
        if (loginUser != null && StringUtils.isNotNull(shoppingVo.getMoney())
                && StringUtils.isNotEmpty(shoppingVo.getGoodsIds()) && shoppingVo.getGoodsIds().size() > 0) {
            try {
                SysUser sysUser = loginUser.getUser();
                String userId = sysUser.getLoginUserId();
                shoppingVo.setUserId(userId);
                return tGoodsService.shoppingBuy(shoppingVo);
            } catch (Exception e) {
                log.error("饰品商城购买异常情况：{}",e.getMessage());
                return Response.fail(Constants.FAILCODE,e.getMessage());
            }
        }else{
            return Response.fail(Constants.FAILCODE,"参数不能为空!");
        }
    }
}
